/* This file is part of xREL
 *
 * Copyright (C) 2012 Timo Zimmermann <xrel@timozimmermann.de>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

import QtQuick 1.1
import com.nokia.meego 1.0

Item {
    id: navigationBar
    y: parent.y + parent.height
    height: 64

    anchors.left: parent.left
    anchors.right: parent.right

    signal reload
    property int page: 1
    property bool show: false

    Separator {
        anchors.top: parent.top
    }

    Button {
        id: pageButton
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        anchors.leftMargin: 12
        width: 80

        enabled: page > 1
        onClicked: page = 1

        Label {
            anchors.centerIn: parent
            text: page
        }
    }

    ButtonRow {
        anchors.centerIn: parent
        width: 250
        exclusive: false

        Button {
            id: backButton
            iconSource: "image://theme/icon-m-toolbar-previous"
            enabled: page > 1
            onClicked: page = page > 1 ? page - 1 : 1
        }

        Button {
            id: refreshButton
            iconSource: "image://theme/icon-m-toolbar-refresh"
            onClicked: reload()
        }

        Button {
            id: nextButton
            iconSource: "image://theme/icon-m-toolbar-next"
            onClicked: page = page + 1
        }
    }

    transitions: Transition {
        NumberAnimation { properties: "y"; easing.type: Easing.InOutQuad }
    }

    Item {
        states: [
            State {
                name: "SHOW"
                when: show && enabled
                PropertyChanges { target: navigationBar; y: parent.y + parent.height - navigationBar.height }
            }
        ]
    }
}
